<template>
	<view>
		<view class="" style="padding: 30rpx;">
			<view class="" style="font-size: 32rpx;font-weight: bold;margin-bottom: 30rpx;">
				退款原因
			</view>
			<textarea placeholder="请输入退款原因" v-model="pay_refund_apply"
				style="border: 1px solid #ccc;width: 95%;padding: 15rpx;border-radius: 10rpx;" />
		</view>
		<view class="bts" @click="tijiao" :style="'background-color: '+theme.main_color+';'">
			提交申请
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				pay_refund_apply: '',
				theme: null
			}
		},
		onLoad(option) {
			this.id = option.id
			this.theme = uni.getStorageSync('theme')
		},
		methods: {
			tijiao() {
				let that = this
				let params = {
					id: that.id,
					pay_refund_apply: that.pay_refund_apply
				}
				if (params.pay_refund_apply == '') {
					return uni.showToast({
						title: '请输入原因'
					})
				}
				uni.showLoading({
					title: '提交中',
					mask:true
				});
				uni.request({
					url: that.global.url + '/api/qianyu_smfw/order/aplly_out_order',
					method: "POST",
					header: {
						'site-id': that.global.site_id, //自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: params,
					success(res) {
						uni.hideLoading();
						let result = res.data
						if (result.code == 1) {
							uni.showModal({
								title: '提示',
								confirmText: '确认', //确定按钮的文字，默认为"确定"
								
								content: '申请已提交，请耐心等待审核',
								showCancel: false, //是否显示取消按钮，默认为 true
								
								success: function(res) {
									if (res.confirm) {
										uni.$emit('order_out',{msg:'订单退款'})
										uni.navigateBack()
									}
								}
							});

						} else {
							uni.showToast({
								title: result.msg,
								//将值设置为 success 或者直接不用写icon这个参数
								icon: 'error',
								//显示持续时间为 2秒
								duration: 2000
							})
						}
					}
				})
			}
		}
	}
</script>

<style>
	.bts {
		width: 87%;
		padding: 20rpx;
		margin: 0px auto;
		color: #fff;
		text-align: center;
		border-radius: 15rpx;
		margin-top: 30rpx;

	}
</style>